#include<iostream>
using namespace std;
typedef struct node{
    int data;
    struct node* next;
}Node;
class Queue{
    public:
    int length;
    Node* head;
    Node* tail;
    Queue();
    void clearQueue();
    int queueLength();
    int isempty();
    int getHead();
    int popHead();
    void  pushBack(int data);// 队列的头指针就是head指针,尾指针就是tail,入队就是尾插,出队就是头插
};
int main(){
   Queue q;
   q.pushBack(1);
   q.pushBack(2);
   q.pushBack(3);
   q.pushBack(4);
   q.pushBack(5);
   q.pushBack(6);
   q.pushBack(7);
   cout<<"出队了"<<q.popHead()<<endl;
   cout<<"出队了"<<q.popHead()<<endl;
   cout<<"出队了"<<q.popHead()<<endl;
   cout<<"出队了"<<q.popHead()<<endl;
   cout<<"出队了"<<q.popHead()<<endl;
   cout<<"出队了"<<q.popHead()<<endl;
   cout<<"出队了"<<q.popHead()<<endl;
   cout<<"出队了"<<q.popHead()<<endl;
  
    return 0;
}
Queue::Queue(){
    this->head=new Node();
    head->data=0;
    head->next=NULL;
    this->tail=head;
    this->length=head->data;
}
void Queue::clearQueue(){
    this->head->data=0;
    this->length=0;
    this->head->next=NULL;
    this->tail=this->head;
}
int Queue::queueLength(){
    return this->length;
}
int Queue::isempty(){
    if(this->length==0){
        return 1;
    }
    else{
        return 0;
    }
}
int Queue::getHead(){
    if(this->isempty()==1){
        cout<<"栈空"<<endl;
        return -1;
    }
    else{
        return head->next->data;    
    }
}
void Queue::pushBack(int data){
        Node* pnew=new Node();
        pnew->data=data;
        tail->next=pnew;
        pnew->next=NULL;
        tail=pnew;
        head->data++;
        this->length++;
}
int Queue::popHead(){
    if(this->isempty()==1){
        cout<<"栈空,弹栈失败"<<endl;
        return -1;
    }
    else{
        head->data--;
        this->length--;
        Node* temp=new Node();
        temp=head->next;
        head->next=temp->next;
        return temp->data;
    }
}